var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("SortChild"),
    s = cc._decorator,
    c = s.ccclass,
    p = s.property,
    l =
        (s.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.onceSortList = [];
                e.cacheData = {};
                e.idCountIndex = {};
                e.isFirst = !1;
                return e;
            }
            e.prototype.setStarSort = function () {
                for (var t = this, e = 0; e < this.onceSortList.length; e++) {
                    var o = this.onceSortList[e];
                    if (o) {
                        for (var a = [], i = 0; i < o.childrenCount && i < 20; i++) {
                            a.push(o.children[i]);
                            break;
                        }
                        if (a.length > 0) {
                            for (i = 0; i < a.length; i++) this.sortData(o, a[i], e);
                            this.scheduleOnce(function () {
                                t.setStarSort();
                            });
                            return;
                        }
                    }
                }
            };
            e.prototype.sortData = function (t, e, o) {
                this.idCountIndex[o] || (this.idCountIndex[o] = 0);
                this.idCountIndex[o]++;
                var a = o + "_" + this.idCountIndex[o];
                this.cacheData[a] = {parent: t, node: e, index: 0, index2: this.idCountIndex[o]};
                e.parent = this.node;
                ParseTool.setSortIndex(e);
                if (e) {
                    var i = e.getComponent(r.default);
                    i && i.starCheckSort();
                }
            };
            e.prototype.onLoad = function () {
                EVUIEffView.on(EVUIEffView.callSort, this.callLevelData.bind(this), this);
            };
            e.prototype.onDestroy = function () {
                EVUIEffView.offTarget(this);
            };
            e.prototype.callLevelData = function (t, e) {
                e && e(this.node);
                if (!this.isFirst) {
                    this.isFirst = !0;
                    this.setStarSort();
                }
            };
            e.prototype.init = function () {};
            n([p([cc.Node])], e.prototype, "onceSortList", void 0);
            return n([c], e);
        })(cc.Component));
o.default = l;
